package com.android.infantschool.ui.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.android.infantschool.R;
import com.android.infantschool.ui.view.NumberProgressBar;

/**
 * author cowards
 * created on 2018\12\19 0019
 **/
public class DialogAppUpdate extends Dialog {

    private NumberProgressBar numberProgressBar;

    public DialogAppUpdate(Context context) {
        super(context, R.style.dialog_loading);
        initLayout();
    }

    private void initLayout() {
        this.setContentView(R.layout.dialog_app_update);
        getWindow().setBackgroundDrawableResource(android.R.color.transparent);
        numberProgressBar = (NumberProgressBar) findViewById(R.id.number_progress);
        this.setCanceledOnTouchOutside(false);//点击dialog背景部分不消失
        this.setCancelable(false);//dialog出现时，点击back键不消失
        Window window = this.getWindow();
        window.setGravity(Gravity.CENTER);
        WindowManager.LayoutParams params = window.getAttributes();
        params.width = WindowManager.LayoutParams.MATCH_PARENT;
        params.height = WindowManager.LayoutParams.WRAP_CONTENT;
        window.setAttributes(params);

    }

    /**
     * 更新当前下载状态
     *
     * @param mProgress 下载进度
     */
    public void setProgress(int mProgress) {
        numberProgressBar.setProgress(mProgress);
    }
}